package com.stone.business.zbtz.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.stone.business.zbtz.pojo.TAqgl;
import com.stone.business.zbtz.service.ZbtzService;
import com.stone.sys.pojo.TDictionary;
import com.stone.sys.service.DictionaryService;
import com.stone.utils.StringUtils;

import frm.ssh.action.BaseListAction;
import frm.ssh.util.SpringUtil;

public class AqglListAction extends BaseListAction {

	private ZbtzService zbtzService;
	// 设备类型
	private List<TDictionary> sblxList;
	@Override
	public HashMap<String, Object> setSearchCondition() {
		HashMap<String, Object> m = new HashMap<String, Object>();
		
		List<Object> valsList = new ArrayList<Object>();
		
		m.put("cols", " a ");
		
		String conditions = " 1=1 "; 
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon6())) {
			conditions += " AND dantype = ?";
			valsList.add(super.getSearchBean().getCon6());
		}
		// 变电站 by wangtao add20120223
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon4())) {
			conditions += " AND a.bdz in (";
			StringBuffer buf= new StringBuffer(""); 
			String[] bdznames = ((String) super.getSearchBean().getCon5() == null? "" : super.getSearchBean().getCon5()).split(",");
			
			for (int i=0; i< bdznames.length; i++) { 
			  if (i!=0) buf.append(", "); 
			  buf.append("" + bdznames[i]+ ""); 
			 
			} 
			buf.append(")"); 
			conditions +=buf;

			
		}
		// 设备类型
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon8())) {
			conditions += " AND a.sblx = '"+super.getSearchBean().getCon8()+"'";
			
		}
		// 查询条件
		m.put("conditions",conditions);
		m.put("alias", " a ");
		m.put("vals", valsList.toArray());
		String forword="";
		if(super.getSearchBean().getCon6().equals("1")){
			forword="FXD_SUCCESS";
			
		}else if(super.getSearchBean().getCon6().equals("2")){
			forword="BWL_SUCCESS";
			
		}
		m.put("forward", forword);
		DictionaryService dicService = (DictionaryService) SpringUtil.getInstance().getBean("dicService");
		//设备类型
		sblxList = dicService.findList("SBLX");
		return m;
	}
	public ZbtzService getZbtzService() {
		return zbtzService;
	}
	public void setZbtzService(ZbtzService zbtzService) {
		this.zbtzService = zbtzService;
		this.service=zbtzService;
	}
	public AqglListAction() {
		this.entityClass = TAqgl.class;
	}
	public List<TDictionary> getSblxList() {
		return sblxList;
	}
	public void setSblxList(List<TDictionary> sblxList) {
		this.sblxList = sblxList;
	}
	
	

}
